#!/bin/bash
#
##############################################################################
#                                                                            #
#                         Pi-Star MOTD Generator.                            #
#                                                                            #
#     Version 0.9, Code, Design and Development by Andy Taylor (MW0MWZ).     #
#                                                                            #
#                   Make it simple to update the /etc/motd.                  #
#                                                                            #
##############################################################################
#
# Make sure we are root, if we cant stop the services, the results are a bit hit and miss.
if [ "$(id -u)" != "0" ]; then
  echo -e "You need to be root to run this command...\n"
  exit 1
fi

# Get the Pi-Star Version Info
pistarCurVersion=$(awk -F "= " '/Version/ {print $2}' /etc/pistar-release)

echo -e "
[0;31m╔═══════════════════════════════════════════════════════════════════════╗
║                                                                       ║
║           ██████╗ ██╗      ███████╗████████╗ █████╗ ██████╗           ║
║           ██╔══██╗██║      ██╔════╝╚══██╔══╝██╔══██╗██╔══██╗          ║
║           ██████╔╝██║█████╗███████╗   ██║   ███████║██████╔╝          ║
║           ██╔═══╝ ██║╚════╝╚════██║   ██║   ██╔══██║██╔══██╗          ║
║           ██║     ██║      ███████║   ██║   ██║  ██║██║  ██║          ║
║           ╚═╝     ╚═╝      ╚══════╝   ╚═╝   ╚═╝  ╚═╝╚═╝  ╚═╝          ║
║                                                                       ║
╚═══════════════════════════════════════════════════════════════════════╝
[0;0mThe Pi-Star Dashboard can be found at one of the following locations:
[1;37mhttp://$(hostname)/  http://$(hostname).local/   http://$(hostname -I | awk '{print $1}')/

[0;0mPi-Star's disk is read-only by default, enable read-write with \"rpi-rw\".
Pi-Star built by Andy Taylor (MW0MWZ), pi-star tools all start \"pistar-\".

                     Welcome to Pi-Star:[0;31m v${pistarCurVersion}
[0;0m" > /etc/motd
